package com.xique.door.listener;


import com.xique.common.core.utils.StringUtils;
import com.xique.door.bean.domain.User;
import com.xique.door.constant.AccessCommandConstant;
import com.xique.door.device.command.AccessCommandHQService;
import com.xique.door.event.AddDeviceBatchCommandEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.stream.Collectors;

/**
 * @author shd
 * @create 2021/7/3 10:17
 */
@Component
public class AddDeviceBatchCommandListener implements ApplicationListener<AddDeviceBatchCommandEvent> {

    @Autowired
    private AccessCommandHQService accessCommandService;

    /**
     *
     * @author shd
     * @date 2021/7/5 8:57
     * @param event 事件参数
     */
    @Override
    @Async
    public void onApplicationEvent(AddDeviceBatchCommandEvent event) {
//        Object o = accessCommandService.downBatchUserInfos(event.getDevSns(), event.getUsers(), AccessCommandConstant.VERSION);
//        System.out.println("==========》批量新增设备信息下发:" + event.getDevSns() + "===========>" + StringUtils.join(event.getUsers().stream().map(User::getId).collect(Collectors.toList())) + "===========>"+ o.toString());
    }
}
